package com.jstyle.beatecg.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.jstyle.beatecg.fragment.ActivityFragment;
import com.jstyle.beatecg.fragment.ChartFragment;
import com.jstyle.beatecg.fragment.ProgresFragment;
import com.jstyle.beatecg.fragment.SportFragment;
import com.jstyle.beatecg.fragment.TrackFragment;

import java.util.List;

/**
 * Created by Administrator on 2017/12/25.
 */

public class SportViewPagerAdapter extends FragmentPagerAdapter {
    public SportViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }
    String speed;
    String heart;
    public SportViewPagerAdapter(FragmentManager fm, String speed,String heart) {
        super(fm);
        this.speed=speed;
        this.heart=heart;
    }
    ChartFragment chartFragment;
    ProgresFragment progresFragment;
    @Override
    public Fragment getItem(int position) {
        switch (position){
            case 0:
                if(chartFragment==null){
                    chartFragment=ChartFragment.newInstance(speed,heart);
                }
                return chartFragment;
            case 1:
                if(progresFragment==null)progresFragment=ProgresFragment.newInstance();
              return progresFragment;
        }
        return null;
    }

    @Override
    public int getCount() {
        return 2;
    }
}
